package com.tolerate.managespringboot.common;

public enum Constants {
    SUCCESS_200(200, "成功"),
    FAIL_500(500, "失败"),
    FAIL_401(401, "权限不足"),
    DICT_TYPE_ICON("icon"),

    ROLE_ADMIN("ROLE_ADMIN"),

    ROLE_USER("ROLE_USER");

    private Integer code;
    private String msg;


    Constants(String msg) {
        this.msg = msg;
    }

    Constants(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }


    // 获取code
    public Integer getCode() {
        return code;
    }

    // 获取msg
    public String getMsg() {
        return msg;
    }

    // 根据code获取msg
    public static String getMsgByCode(Integer code) {
        for (Constants c : Constants.values()) {
            if (c.getCode().equals(code)) {
                return c.getMsg();
            }
        }
        return null;
    }
}
